/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */


{%- macro to_java_return_type(type) -%}
  {%- if type == "string" -%}
    String
  {%- elif type == "string[]" -%}
    List<String>
  {%- elif type == "boolean" -%}
    boolean
  {%- elif type == "int" -%}
    long
  {%- elif type == "double" -%}
    double
  {%- else -%}
    {{type}}
  {%- endif -%}
{%- endmacro %}
{%- macro to_java_key_type(type) -%}
  {%- if type == "string" -%}
    stringKey
  {%- elif type == "string[]" -%}
    stringArrayKey
  {%- elif type == "boolean" -%}
    booleanKey
  {%- elif type == "int" -%}
    longKey
  {%- elif type == "double" -%}
    doubleKey
  {%- else -%}
    {{lowerFirst(type)}}Key
  {%- endif -%}
{%- endmacro %}
{%- macro print_value(type, value) -%}
  {{ "\"" if type == "String"}}{{value}}{{ "\"" if type == "String"}}
{%- endmacro %}
{%- macro upFirst(text) -%}
  {{ text[0]|upper}}{{text[1:] }}
{%- endmacro %}
{%- macro lowerFirst(text) -%}
  {{ text[0]|lower}}{{text[1:] }}
{%- endmacro %}

package {{pkg | trim}};

import static io.opentelemetry.api.common.AttributeKey.booleanKey;
import static io.opentelemetry.api.common.AttributeKey.doubleKey;
import static io.opentelemetry.api.common.AttributeKey.longKey;
import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.api.common.AttributeKey.stringArrayKey;

import io.opentelemetry.api.common.AttributeKey;
import java.util.List;

// DO NOT EDIT, this is an Auto-generated file from buildscripts/semantic-convention{{template}}
@SuppressWarnings("unused")
public final class {{class}} {
  /**
   * The URL of the OpenTelemetry schema for these keys and values.
   */
  public static final String SCHEMA_URL = "{{schemaUrl}}";
  {%- for attribute in attributes if attribute.is_local and not attribute.ref %}

  /**
  * {{attribute.brief | render_markdown(code="{{@code {0}}}", paragraph="{0}")}}
    {%- if attribute.note %}
  *
  * <p>Notes:
    <ul> {{attribute.note | render_markdown(code="{{@code {0}}}", paragraph="<li>{0}</li>", list="{0}")}} </ul>
    {%- endif %}
    {%- if (attribute.stability | string())  == "StabilityLevel.DEPRECATED" %}
  *
  * @deprecated {{attribute.brief | to_doc_brief}}.
    {%- endif %}
  */
    {%- if (attribute.stability | string()) == "StabilityLevel.DEPRECATED"  %}
  @Deprecated
    {%- endif %}
  public static final AttributeKey<{{upFirst(to_java_return_type(attribute.attr_type | string))}}> {{attribute.fqn | to_const_name}} = {{to_java_key_type(attribute.attr_type | string)}}("{{attribute.fqn}}");
  {%- endfor %}

  // Enum definitions
  {%- for attribute in attributes if attribute.is_local and not attribute.ref %}
  {%- if attribute.is_enum %}
  {%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %}
  {%- set type = to_java_return_type(attribute.attr_type.enum_type) %}
  public static final class {{class_name}} {
    {%- for member in attribute.attr_type.members %}
      /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */
      public static final {{ type }} {{ member.member_id | to_const_name }} = {{ print_value(type, member.value) }};

    {%- endfor %}

    {%- if class_name == "NetTransportValues" %}
    /** @deprecated This item has been removed as of 1.13.0 of the semantic conventions. */
    @Deprecated
    public static final String IP = "ip";

    /** @deprecated This item has been removed as of 1.13.0 of the semantic conventions. */
    @Deprecated
    public static final String UNIX = "unix";
    {%- endif %}

      private {{ class_name }}() {}
  }

  {% endif %}
  {%- endfor %}

  {%- if class == "SemanticAttributes" %}
  // Manually defined and not YET in the YAML
  /**
   * The name of an event describing an exception.
   *
   * <p>Typically an event with that name should not be manually created. Instead {@link
   * io.opentelemetry.api.trace.Span#recordException(Throwable)} should be used.
   */
  public static final String EXCEPTION_EVENT_NAME = "exception";

  /**
   * The name of the keyspace being accessed.
   *
   * @deprecated this item has been removed as of 1.8.0 of the semantic conventions. Please use {@link SemanticAttributes#DB_NAME} instead.
   */
  @Deprecated
  public static final AttributeKey<String> DB_CASSANDRA_KEYSPACE =
      stringKey("db.cassandra.keyspace");

  /**
   * The <a href="https://hbase.apache.org/book.html#_namespace">HBase namespace</a> being accessed.
   *
   * @deprecated this item has been removed as of 1.8.0 of the semantic conventions. Please use {@link SemanticAttributes#DB_NAME} instead.
   */
  @Deprecated
  public static final AttributeKey<String> DB_HBASE_NAMESPACE = stringKey("db.hbase.namespace");

  /**
   * The size of the uncompressed request payload body after transport decoding. Not set if
   * transport encoding not used.
   *
   * @deprecated  this item has been removed as of 1.13.0 of the semantic conventions. Please use {@link SemanticAttributes#HTTP_REQUEST_CONTENT_LENGTH} instead.
   */
  @Deprecated
  public static final AttributeKey<Long> HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED =
      longKey("http.request_content_length_uncompressed");

  /**
   * @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use {@link SemanticAttributes#HTTP_RESPONSE_CONTENT_LENGTH} instead.
   */
  @Deprecated
  public static final AttributeKey<Long> HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED =
        longKey("http.response_content_length_uncompressed");

  /**
   * @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use
   *     {@link SemanticAttributes#NET_HOST_NAME} instead.
   */
  @Deprecated
  public static final AttributeKey<String> HTTP_SERVER_NAME = stringKey("http.server_name");

  /**
   * @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use
   *     {@link SemanticAttributes#NET_HOST_NAME} instead.
   */
  @Deprecated
  public static final AttributeKey<String> HTTP_HOST = stringKey("http.host");

  /**
   * @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use {@link SemanticAttributes#NET_SOCK_PEER_ADDR} instead.
   */
  @Deprecated
  public static final AttributeKey<String> NET_PEER_IP = stringKey("net.peer.ip");

  /**
   * @deprecated This item has been removed as of 1.13.0 of the semantic conventions. Please use {@link SemanticAttributes#NET_SOCK_HOST_ADDR} instead.
   */
  @Deprecated
  public static final AttributeKey<String> NET_HOST_IP = stringKey("net.host.ip");

  /**
   * The ordinal number of request re-sending attempt.
   * @deprecated This item has been removed as of 1.15.0 of the semantic conventions. Use {@link SemanticAttributes#HTTP_RESEND_COUNT} instead.
   */
  @Deprecated
  public static final AttributeKey<Long> HTTP_RETRY_COUNT = longKey("http.retry_count");


 /**
  * A string identifying the messaging system.
  * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#MESSAGING_DESTINATION_NAME} instead.
  */
  @Deprecated
  public static final AttributeKey<String> MESSAGING_DESTINATION =
      stringKey("messaging.destination");

 /**
  * A boolean that is true if the message destination is temporary.
  * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#MESSAGING_DESTINATION_TEMPORARY} instead.
  */
  @Deprecated
  public static final AttributeKey<Boolean> MESSAGING_TEMP_DESTINATION =
      booleanKey("messaging.temp_destination");

 /**
  * The name of the transport protocol.
  * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#NET_PROTOCOL_NAME} instead.
  */
  @Deprecated
  public static final AttributeKey<String> MESSAGING_PROTOCOL = stringKey("messaging.protocol");

  /**
  * The version of the transport protocol.
  * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#NET_PROTOCOL_VERSION} instead.
  */
  @Deprecated
  public static final AttributeKey<String> MESSAGING_PROTOCOL_VERSION =
      stringKey("messaging.protocol_version");

  /**
  * Connection string.
  * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. There is no replacement.
  */
  @Deprecated
  public static final AttributeKey<String> MESSAGING_URL = stringKey("messaging.url");

   /**
    * The <a href="#conversations">conversation ID</a> identifying the conversation to which the
    * message belongs, represented as a string. Sometimes called &quot;Correlation ID&quot;.
    * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#MESSAGING_MESSAGE_CONVERSATION_ID} instead.
    */
   @Deprecated
   public static final AttributeKey<String> MESSAGING_CONVERSATION_ID =
      stringKey("messaging.conversation_id");

  /**
   * RabbitMQ message routing key.
   * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY} instead.
   */
  @Deprecated
  public static final AttributeKey<String> MESSAGING_RABBITMQ_ROUTING_KEY =
      stringKey("messaging.rabbitmq.routing_key");

  /**
   * Partition the message is received from.
   * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#MESSAGING_KAFKA_SOURCE_PARTITION} instead.
   */
   @Deprecated
  public static final AttributeKey<Long> MESSAGING_KAFKA_PARTITION =
      longKey("messaging.kafka.partition");

  /**
   * A boolean that is true if the message is a tombstone.
   * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#MESSAGING_KAFKA_MESSAGE_TOMBSTONE} instead.
   */
  @Deprecated
  public static final AttributeKey<Boolean> MESSAGING_KAFKA_TOMBSTONE =
      booleanKey("messaging.kafka.tombstone");

  /**
   * The timestamp in milliseconds that the delay message is expected to be delivered to consumer.
   * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#MESSAGING_ROCKETMQ_MESSAGE_DELIVERY_TIMESTAMP} instead.
   */
  @Deprecated
  public static final AttributeKey<Long> MESSAGING_ROCKETMQ_DELIVERY_TIMESTAMP =
      longKey("messaging.rocketmq.delivery_timestamp");


  /**
   * The delay time level for delay message, which determines the message delay time.
   * @deprecated This item has been removed as of 1.17.0 of the semantic conventions. Use {@link SemanticAttributes#MESSAGING_ROCKETMQ_MESSAGE_DELAY_TIME_LEVEL} instead.
   */
  @Deprecated
  public static final AttributeKey<Long> MESSAGING_ROCKETMQ_DELAY_TIME_LEVEL =
      longKey("messaging.rocketmq.delay_time_level");

  /** 
   * The name of the instrumentation scope - ({@code InstrumentationScope.Name} in OTLP).
   * @deprecated This item has been moved, use {@link io.opentelemetry.semconv.resource.attributes.ResourceAttributes#OTEL_SCOPE_NAME} instead.
   */
  @Deprecated
  public static final AttributeKey<String> OTEL_SCOPE_NAME = stringKey("otel.scope.name");

  /** 
   * The version of the instrumentation scope - ({@code InstrumentationScope.Version} in OTLP).
   * @deprecated This item has been moved, use {@link io.opentelemetry.semconv.resource.attributes.ResourceAttributes#OTEL_SCOPE_VERSION} instead.
   */
  @Deprecated
  public static final AttributeKey<String> OTEL_SCOPE_VERSION = stringKey("otel.scope.version");

  /**
   * The execution ID of the current function execution.
   * @deprecated This item has been renamed in 1.19.0 version of the semantic conventions. 
   * Use {@link SemanticAttributes#FAAS_INVOCATION_ID} instead.
   */
  @Deprecated
  public static final AttributeKey<String> FAAS_EXECUTION = stringKey("faas.execution");

  /**
   * Value of the <a href="https://www.rfc-editor.org/rfc/rfc9110.html#field.user-agent">HTTP
   * User-Agent</a> header sent by the client.
   * @deprecated This item has been renamed in 1.19.0 version of the semantic conventions. 
   * Use {@link SemanticAttributes#USER_AGENT_ORIGINAL} instead.
   */
  @Deprecated
  public static final AttributeKey<String> HTTP_USER_AGENT = stringKey("http.user_agent");

  /**
   * Deprecated.
   *
   * @deprecated Deprecated, use the {@link io.opentelemetry.semconv.resource.attributes.ResourceAttributes#OTEL_SCOPE_NAME} attribute.
   */
  @Deprecated
  public static final AttributeKey<String> OTEL_LIBRARY_NAME = stringKey("otel.library.name");

  /**
   * Deprecated.
   *
   * @deprecated Deprecated, use the {@link io.opentelemetry.semconv.resource.attributes.ResourceAttributes#OTEL_SCOPE_VERSION} attribute.
   */
  @Deprecated
  public static final AttributeKey<String> OTEL_LIBRARY_VERSION = stringKey("otel.library.version");

  /**
   * Kind of HTTP protocol used.
   * @deprecated This item has been removed as of 1.20.0 of the semantic conventions.
   */
  @Deprecated
  public static final AttributeKey<String> HTTP_FLAVOR = stringKey("http.flavor");

  /**
   * Enum definitions for {@link #HTTP_FLAVOR}.
   * @deprecated This item has been removed as of 1.20.0 of the semantic conventions.
   */
  @Deprecated
  public static final class HttpFlavorValues {
    /** HTTP/1.0. */
    public static final String HTTP_1_0 = "1.0";

    /** HTTP/1.1. */
    public static final String HTTP_1_1 = "1.1";

    /** HTTP/2. */
    public static final String HTTP_2_0 = "2.0";

    /** HTTP/3. */
    public static final String HTTP_3_0 = "3.0";

    /** SPDY protocol. */
    public static final String SPDY = "SPDY";

    /** QUIC protocol. */
    public static final String QUIC = "QUIC";

    private HttpFlavorValues() {}
  }

  /**
   * Application layer protocol used. The value SHOULD be normalized to lowercase.
   * @deprecated This item has been removed as of 1.20.0 of the semantic conventions. Use {@link SemanticAttributes#NET_PROTOCOL_NAME} instead.
   */
  @Deprecated
  public static final AttributeKey<String> NET_APP_PROTOCOL_NAME = stringKey("net.app.protocol.name");

  /**
   * Version of the application layer protocol used. See note below.
   *
   * <p>Notes:
   *
   * <ul>
   *   <li>{@code net.app.protocol.version} refers to the version of the protocol used and might be
   *       different from the protocol client's version. If the HTTP client used has a version of
   *       {@code 0.27.2}, but sends HTTP version {@code 1.1}, this attribute should be set to
   *       {@code 1.1}.
   * </ul>
   * @deprecated This item has been removed as of 1.20.0 of the semantic conventions. Use {@link SemanticAttributes#NET_PROTOCOL_VERSION} instead.
   */
  @Deprecated
  public static final AttributeKey<String> NET_APP_PROTOCOL_VERSION = stringKey("net.app.protocol.version");

  /**
   * The kind of message destination.
   * @deprecated This item has been removed as of 1.20.0 of the semantic conventions.
   */
  @Deprecated
  public static final AttributeKey<String> MESSAGING_DESTINATION_KIND = stringKey("messaging.destination.kind");

  /**
   * Enum values for {@link #MESSAGING_DESTINATION_KIND}.
   * @deprecated This item has been removed as of 1.20.0 of the semantic conventions.
   */
  @Deprecated
  public static final class MessagingDestinationKindValues {
    /** A message sent to a queue. */
    public static final String QUEUE = "queue";

    /** A message sent to a topic. */
    public static final String TOPIC = "topic";

    private MessagingDestinationKindValues() {}
  }

  /**
   * The kind of message source.
   * @deprecated This item has been removed as of 1.20.0 of the semantic conventions.
   */
  @Deprecated
  public static final AttributeKey<String> MESSAGING_SOURCE_KIND = stringKey("messaging.source.kind");

  /**
   * Enum values for {@link #MESSAGING_SOURCE_KIND}.
   * @deprecated This item has been removed as of 1.20.0 of the semantic conventions.
   */
  @Deprecated
  public static final class MessagingSourceKindValues {
    /** A message received from a queue. */
    public static final String QUEUE = "queue";

    /** A message received from a topic. */
    public static final String TOPIC = "topic";

    private MessagingSourceKindValues() {}
  }

  {% endif %}

  {%- if class == "ResourceAttributes" %}

  /**
   * Red Hat OpenShift on Google Cloud.
   * @deprecated This item has been removed as of 1.18.0 of the semantic conventions. Use {@link ResourceAttributes#GCP_OPENSHIFT} instead.
   */
  @Deprecated
  public static final String GCP_OPENSHIFT = "gcp_openshift";

  /**
   * Full user-agent string provided by the browser
   *
   * <p>Notes:
   *
   * <ul>
   *   <li>The user-agent value SHOULD be provided only from browsers that do not have a mechanism
   *       to retrieve brands and platform individually from the User-Agent Client Hints API. To
   *       retrieve the value, the legacy {@code navigator.userAgent} API can be used.
   * </ul>
   * @deprecated This item has been renamed in 1.19.0 version of the semantic conventions. Use {@link io.opentelemetry.semconv.trace.attributes.SemanticAttributes#USER_AGENT_ORIGINAL} instead.
   */
  @Deprecated
  public static final AttributeKey<String> BROWSER_USER_AGENT = stringKey("browser.user_agent");

  /**
   * The unique ID of the single function that this runtime instance executes.
   *
   * <p>Notes:
   *
   * <ul>
   *   <li>On some cloud providers, it may not be possible to determine the full ID at startup, so
   *       consider setting {@code faas.id} as a span attribute instead.
   *   <li>The exact value to use for {@code faas.id} depends on the cloud provider:
   *   <li><strong>AWS Lambda:</strong> The function <a
   *       href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">ARN</a>.
   *       Take care not to use the &quot;invoked ARN&quot; directly but replace any <a
   *       href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html">alias
   *       suffix</a> with the resolved function version, as the same runtime instance may be
   *       invokable with multiple different aliases.
   *   <li><strong>GCP:</strong> The <a
   *       href="https://cloud.google.com/iam/docs/full-resource-names">URI of the resource</a>
   *   <li><strong>Azure:</strong> The <a
   *       href="https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id">Fully
   *       Qualified Resource ID</a> of the invoked function, <em>not</em> the function app, having
   *       the form {@code
   *       /subscriptions/<SUBSCIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>}.
   *       This means that a span attribute MUST be used, as an Azure function app can host multiple
   *       functions that would usually share a TracerProvider.
   * </ul>
   * @deprecated This item has been removed in 1.19.0 version of the semantic conventions. Use {@link ResourceAttributes#CLOUD_RESOURCE_ID} instead.
   */
  @Deprecated
  public static final AttributeKey<String> FAAS_ID = stringKey("faas.id");

  {% endif %}

  private {{class}}() {}
}
